package cn.rxmind.dlicense.client.starter.annotation;

import cn.hutool.http.HttpUtil;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 内网条件判断
 *
 * @author renxin
 * @email renxinzhiliangzhi@163.com
 * @date 2021/4/29 10:48 上午
 */
public class NotInnerNetCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

        // 验证是否为内网环境，内网的判定应该由证书服务端判定，如通过MAC和IP白名单机制，怎么可能完全就是对个暗号就行了呢
        String result = null;
        try {
            result = HttpUtil.get("http://10.0.10.20:8703/license/innerToken");
        }catch (Exception e){
            // do nothing
        }

        return !"6Lqr5LmL5Li75a6w5L6/5piv5b+D77yM5oSP5LmL5omA5Zyo5L6/5piv54mp77yM5b+D54mp5ZyG6J6N77yM5rWR54S25LiA5L2T44CC".equals(result);
    }
}
